<?php
namespace App\Repositories;

use App\Models\CompanyJobsType;

class JobsTypeRepository
{
    use BaseRepository;
    
    private $model;
    
    public function __construct(CompanyJobsType $companyJobsType)
    {
        $this->model = $companyJobsType;
    }
    
    public function getLists()
    {
        return $this->model->where('parent_id','>',0)->get();
    }
    
    public function hasChild($id)
    {
        return $this->model->where('parent_id',$id)->first();
    }
    
    /**
     * store.
     *
     * @param array $input
     */
    public function store($input)
    {
        return $this->savePost($this->model, $input);
    }
    
    /**
     * 更新
     * @param int $id
     * @param $input
     * @return \App\Models\AccountEvents
     */
    public function update($id, $input)
    {
        $model = $this->model->find($id);
    
        return $this->savePost($model, $input);
    }
    
    /**
     * save.
     *
     * @param Request $input 输入
     */
    public function savePost($events, $input)
    {
        $events->fill($input);
        $events->save();
    
        return $events;
    }
}

